home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / namcos1.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  40KB  |  1,392 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4. #define NEW_TIMER 0 /* CPU slice optimize with new timer system */
  5.  
  6. #define NAMCOS1_MAX_BANK 0x400
  7.  
  8. /* from vidhrdw */
  9. READ_HANDLER( namcos1_videoram_r );
  10. WRITE_HANDLER( namcos1_videoram_w );
  11. READ_HANDLER( namcos1_paletteram_r );
  12. WRITE_HANDLER( namcos1_paletteram_w );
  13. WRITE_HANDLER( namcos1_videocontrol_w );
  14. extern void namcos1_set_scroll_offsets( const int *bgx, const int *bgy, int negative, int optimize );
  15. extern void namcos1_set_optimize( int optimize );
  16. extern void namcos1_set_sprite_offsets( int x, int y );
  17.  
  18. #define NAMCOS1_MAX_KEY 0x100
  19. static unsigned char key[NAMCOS1_MAX_KEY];
  20.  
  21. static unsigned char *s1ram;
  22.  
  23. static int namcos1_cpu1_banklatch;
  24. static int namcos1_reset = 0;
  25.  
  26.  
  27. static int berabohm_input_counter;
  28.  
  29.  
  30.  
  31. /*******************************************************************************
  32. *                                                                               *
  33. *    Key emulation (CUS136) Rev1 (Pacmania & Galaga 88)                           *
  34. *                                                                               *
  35. *******************************************************************************/
  36.  
  37. static int key_id;
  38. static int key_id_query;
  39.  
  40. static READ_HANDLER( rev1_key_r ) {
  41. //    logerror("CPU #%d PC %08x: keychip read %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,key[offset]);
  42.     if(offset >= NAMCOS1_MAX_KEY)
  43.     {
  44.         logerror("CPU #%d PC %08x: unmapped keychip read %04x\n",cpu_getactivecpu(),cpu_get_pc(),offset);
  45.         return 0;
  46.     }
  47.     return key[offset];
  48. }
  49.  
  50. static WRITE_HANDLER( rev1_key_w ) {
  51.     static unsigned short divider, divide_32 = 0;
  52.     //logerror("CPU #%d PC %08x: keychip write %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  53.     if(offset >= NAMCOS1_MAX_KEY)
  54.     {
  55.         logerror("CPU #%d PC %08x: unmapped keychip write %04x=%04x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  56.         return;
  57.     }
  58.  
  59.     key[offset] = data;
  60.  
  61.     switch ( offset )
  62.     {
  63.     case 0x01:
  64.         divider = ( key[0] << 8 ) + key[1];
  65.         break;
  66.     case 0x03:
  67.         {
  68.             static unsigned short d;
  69.             unsigned short    v1, v2;
  70.             unsigned long    l=0;
  71.  
  72.             if ( divide_32 )
  73.                 l = d << 16;
  74.  
  75.             d = ( key[2] << 8 ) + key[3];
  76.  
  77.             if ( divider == 0 ) {
  78.                 v1 = 0xffff;
  79.                 v2 = 0;
  80.             } else {
  81.                 if ( divide_32 ) {
  82.                     l |= d;
  83.  
  84.                     v1 = l / divider;
  85.                     v2 = l % divider;
  86.                 } else {
  87.                     v1 = d / divider;
  88.                     v2 = d % divider;
  89.                 }
  90.             }
  91.  
  92.             key[2] = v1 >> 8;
  93.             key[3] = v1;
  94.             key[0] = v2 >> 8;
  95.             key[1] = v2;
  96.         }
  97.         break;
  98.     case 0x04:
  99.         if ( key[4] == key_id_query ) /* get key number */
  100.             key[4] = key_id;
  101.  
  102.         if ( key[4] == 0x0c )
  103.             divide_32 = 1;
  104.         else
  105.             divide_32 = 0;
  106.         break;
  107.     }
  108. }
  109.  
  110. /*******************************************************************************
  111. *                                                                               *
  112. *    Key emulation (CUS136) Rev2 (Dragon Spirit, Blazer, World Court)           *
  113. *                                                                               *
  114. *******************************************************************************/
  115.  
  116. static READ_HANDLER( rev2_key_r )
  117. {
  118.     //logerror("CPU #%d PC %08x: keychip read %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,key[offset]);
  119.     if(offset >= NAMCOS1_MAX_KEY)
  120.     {
  121.         logerror("CPU #%d PC %08x: unmapped keychip read %04x\n",cpu_getactivecpu(),cpu_get_pc(),offset);
  122.         return 0;
  123.     }
  124.     return key[offset];
  125. }
  126.  
  127. static WRITE_HANDLER( rev2_key_w )
  128. {
  129.     //logerror("CPU #%d PC %08x: keychip write %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  130.     if(offset >= NAMCOS1_MAX_KEY)
  131.     {
  132.         logerror("CPU #%d PC %08x: unmapped keychip write %04x=%04x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  133.         return;
  134.     }
  135.     key[offset] = data;
  136.  
  137.     switch(offset)
  138.     {
  139.     case 0x00:
  140.         if ( data == 1 )
  141.         {
  142.             /* fetch key ID */
  143.             key[3] = key_id;
  144.             return;
  145.         }
  146.         break;
  147.     case 0x02:
  148.         /* $f2 = Dragon Spirit, $b7 = Blazer , $35($d9) = worldcourt */
  149.         if ( key[3] == 0xf2 || key[3] == 0xb7 || key[3] == 0x35 )
  150.         {
  151.             switch( key[0] )
  152.             {
  153.                 case 0x10: key[0] = 0x05; key[1] = 0x00; key[2] = 0xc6; break;
  154.                 case 0x12: key[0] = 0x09; key[1] = 0x00; key[2] = 0x96; break;
  155.                 case 0x15: key[0] = 0x0a; key[1] = 0x00; key[2] = 0x8f; break;
  156.                 case 0x22: key[0] = 0x14; key[1] = 0x00; key[2] = 0x39; break;
  157.                 case 0x32: key[0] = 0x31; key[1] = 0x00; key[2] = 0x12; break;
  158.                 case 0x3d: key[0] = 0x35; key[1] = 0x00; key[2] = 0x27; break;
  159.                 case 0x54: key[0] = 0x10; key[1] = 0x00; key[2] = 0x03; break;
  160.                 case 0x58: key[0] = 0x49; key[1] = 0x00; key[2] = 0x23; break;
  161.                 case 0x7b: key[0] = 0x48; key[1] = 0x00; key[2] = 0xd4; break;
  162.                 case 0xc7: key[0] = 0xbf; key[1] = 0x00; key[2] = 0xe8; break;
  163.             }
  164.             return;
  165.         }
  166.         break;
  167.     case 0x03:
  168.         /* $c2 = Dragon Spirit, $b6 = Blazer */
  169.         if ( key[3] == 0xc2 || key[3] == 0xb6 ) {
  170.             key[3] = 0x36;
  171.             return;
  172.         }
  173.         /* $d9 = World court */
  174.         if ( key[3] == 0xd9 )
  175.         {
  176.             key[3] = 0x35;
  177.             return;
  178.         }
  179.         break;
  180.     case 0x3f:    /* Splatter House */
  181.         key[0x3f] = 0xb5;
  182.         key[0x36] = 0xb5;
  183.         return;
  184.     }
  185.     /* ?? */
  186.     if ( key[3] == 0x01 ) {
  187.         if ( key[0] == 0x40 && key[1] == 0x04 && key[2] == 0x00 ) {
  188.             key[1] = 0x00; key[2] = 0x10;
  189.             return;
  190.         }
  191.     }
  192. }
  193.  
  194. /*******************************************************************************
  195. *                                                                               *
  196. *    Key emulation (CUS136) for Dangerous Seed                                   *
  197. *                                                                               *
  198. *******************************************************************************/
  199.  
  200. static READ_HANDLER( dangseed_key_r ) {
  201. //    logerror("CPU #%d PC %08x: keychip read %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,key[offset]);
  202.     if(offset >= NAMCOS1_MAX_KEY)
  203.     {
  204.         logerror("CPU #%d PC %08x: unmapped keychip read %04x\n",cpu_getactivecpu(),cpu_get_pc(),offset);
  205.         return 0;
  206.     }
  207.     return key[offset];
  208. }
  209.  
  210. static WRITE_HANDLER( dangseed_key_w ) {
  211.     int i;
  212. //    logerror("CPU #%d PC %08x: keychip write %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  213.     if(offset >= NAMCOS1_MAX_KEY)
  214.     {
  215.         logerror("CPU #%d PC %08x: unmapped keychip write %04x=%04x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  216.         return;
  217.     }
  218.  
  219.     key[offset] = data;
  220.  
  221.     switch ( offset )
  222.     {
  223.         case 0x50:
  224.             for ( i = 0; i < 0x50; i++ ) {
  225.                 key[i] = ( data >> ( ( i >> 4 ) & 0x0f ) ) & 0x0f;
  226.                 key[i] |= ( i & 0x0f ) << 4;
  227.             }
  228.             break;
  229.  
  230.         case 0x57:
  231.             key[3] = key_id;
  232.             break;
  233.     }
  234. }
  235.  
  236. /*******************************************************************************
  237. *                                                                               *
  238. *    Key emulation (CUS136) for Dragon Spirit                                   *
  239. *                                                                               *
  240. *******************************************************************************/
  241.  
  242. static READ_HANDLER( dspirit_key_r )
  243. {
  244.     //logerror("CPU #%d PC %08x: keychip read %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,key[offset]);
  245.     if(offset >= NAMCOS1_MAX_KEY)
  246.     {
  247.         logerror("CPU #%d PC %08x: unmapped keychip read %04x\n",cpu_getactivecpu(),cpu_get_pc(),offset);
  248.         return 0;
  249.     }
  250.     return key[offset];
  251. }
  252.  
  253. static WRITE_HANDLER( dspirit_key_w )
  254. {
  255.     static unsigned short divisor;
  256. //    logerror("CPU #%d PC %08x: keychip write %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  257.     if(offset >= NAMCOS1_MAX_KEY)
  258.     {
  259.         logerror("CPU #%d PC %08x: unmapped keychip write %04x=%04x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  260.         return;
  261.     }
  262.     key[offset] = data;
  263.  
  264.     switch(offset)
  265.     {
  266.     case 0x00:
  267.         if ( data == 1 )
  268.         {
  269.             /* fetch key ID */
  270.             key[3] = key_id;
  271.         } else
  272.             divisor = data;
  273.         break;
  274.  
  275.     case 0x01:
  276.         if ( key[3] == 0x01 ) { /* division gets resolved on latch to $1 */
  277.             unsigned short d, v1, v2;
  278.  
  279.             d = ( key[1] << 8 ) + key[2];
  280.  
  281.             if ( divisor == 0 ) {
  282.                 v1 = 0xffff;
  283.                 v2 = 0;
  284.             } else {
  285.                 v1 = d / divisor;
  286.                 v2 = d % divisor;
  287.             }
  288.  
  289.             key[0] = v2 & 0xff;
  290.             key[1] = v1 >> 8;
  291.             key[2] = v1 & 0xff;
  292.  
  293.             return;
  294.         }
  295.  
  296.         if ( key[3] != 0xf2 ) { /* if its an invalid mode, clear regs */
  297.             key[0] = 0;
  298.             key[1] = 0;
  299.             key[2] = 0;
  300.         }
  301.         break;
  302.     case 0x02:
  303.         if ( key[3] == 0xf2 ) { /* division gets resolved on latch to $2 */
  304.             unsigned short d, v1, v2;
  305.  
  306.             d = ( key[1] << 8 ) + key[2];
  307.  
  308.             if ( divisor == 0 ) {
  309.                 v1 = 0xffff;
  310.                 v2 = 0;
  311.             } else {
  312.                 v1 = d / divisor;
  313.                 v2 = d % divisor;
  314.             }
  315.  
  316.             key[0] = v2 & 0xff;
  317.             key[1] = v1 >> 8;
  318.             key[2] = v1 & 0xff;
  319.  
  320.             return;
  321.         }
  322.  
  323.         if ( key[3] != 0x01 ) { /* if its an invalid mode, clear regs */
  324.             key[0] = 0;
  325.             key[1] = 0;
  326.             key[2] = 0;
  327.         }
  328.         break;
  329.     case 0x03:
  330.         if ( key[3] != 0xf2 && key[3] != 0x01 ) /* if the mode is unknown return the id on $3 */
  331.             key[3] = key_id;
  332.         break;
  333.     }
  334. }
  335.  
  336. /*******************************************************************************
  337. *                                                                               *
  338. *    Key emulation (CUS136) for Blazer                                           *
  339. *                                                                               *
  340. *******************************************************************************/
  341.  
  342. static READ_HANDLER( blazer_key_r )
  343. {
  344.     logerror("CPU #%d PC %08x: keychip read %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,key[offset]);
  345.     if(offset >= NAMCOS1_MAX_KEY)
  346.     {
  347.         logerror("CPU #%d PC %08x: unmapped keychip read %04x\n",cpu_getactivecpu(),cpu_get_pc(),offset);
  348.         return 0;
  349.     }
  350.     return key[offset];
  351. }
  352.  
  353. static WRITE_HANDLER( blazer_key_w )
  354. {
  355.     static unsigned short divisor;
  356.     logerror("CPU #%d PC %08x: keychip write %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  357.     if(offset >= NAMCOS1_MAX_KEY)
  358.     {
  359.         logerror("CPU #%d PC %08x: unmapped keychip write %04x=%04x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  360.         return;
  361.     }
  362.     key[offset] = data;
  363.  
  364.     switch(offset)
  365.     {
  366.     case 0x00:
  367.         if ( data == 1 )
  368.         {
  369.             /* fetch key ID */
  370.             key[3] = key_id;
  371.         } else
  372.             divisor = data;
  373.         break;
  374.  
  375.     case 0x01:
  376.         if ( key[3] != 0xb7 ) { /* if its an invalid mode, clear regs */
  377.             key[0] = 0;
  378.             key[1] = 0;
  379.             key[2] = 0;
  380.         }
  381.         break;
  382.  
  383.     case 0x02:
  384.         if ( key[3] == 0xb7 ) { /* division gets resolved on latch to $2 */
  385.             unsigned short d, v1, v2;
  386.  
  387.             d = ( key[1] << 8 ) + key[2];
  388.  
  389.             if ( divisor == 0 ) {
  390.                 v1 = 0xffff;
  391.                 v2 = 0;
  392.             } else {
  393.                 v1 = d / divisor;
  394.                 v2 = d % divisor;
  395.             }
  396.  
  397.             key[0] = v2 & 0xff;
  398.             key[1] = v1 >> 8;
  399.             key[2] = v1 & 0xff;
  400.  
  401.             return;
  402.         }
  403.  
  404.         /* if its an invalid mode, clear regs */
  405.         key[0] = 0;
  406.         key[1] = 0;
  407.         key[2] = 0;
  408.         break;
  409.     case 0x03:
  410.         if ( key[3] != 0xb7 ) { /* if the mode is unknown return the id on $3 */
  411.             key[3] = key_id;
  412.         }
  413.         break;
  414.     }
  415. }
  416.  
  417. /*******************************************************************************
  418. *                                                                               *
  419. *    Key emulation (CUS136) for World Stadium                                   *
  420. *                                                                               *
  421. *******************************************************************************/
  422.  
  423. static READ_HANDLER( ws_key_r ) {
  424. //    logerror("CPU #%d PC %08x: keychip read %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,key[offset]);
  425.     if(offset >= NAMCOS1_MAX_KEY)
  426.     {
  427.         logerror("CPU #%d PC %08x: unmapped keychip read %04x\n",cpu_getactivecpu(),cpu_get_pc(),offset);
  428.         return 0;
  429.     }
  430.     return key[offset];
  431. }
  432.  
  433. static WRITE_HANDLER( ws_key_w ) {
  434.     static unsigned short divider;
  435.     //logerror("CPU #%d PC %08x: keychip write %04X=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  436.     if(offset >= NAMCOS1_MAX_KEY)
  437.     {
  438.         logerror("CPU #%d PC %08x: unmapped keychip write %04x=%04x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  439.         return;
  440.     }
  441.  
  442.     key[offset] = data;
  443.  
  444.     switch ( offset )
  445.     {
  446.     case 0x01:
  447.         divider = ( key[0] << 8 ) + key[1];
  448.         break;
  449.     case 0x03:
  450.         {
  451.             static unsigned short d;
  452.             unsigned short    v1, v2;
  453.  
  454.             d = ( key[2] << 8 ) + key[3];
  455.  
  456.             if ( divider == 0 ) {
  457.                 v1 = 0xffff;
  458.                 v2 = 0;
  459.             } else {
  460.                 v1 = d / divider;
  461.                 v2 = d % divider;
  462.             }
  463.  
  464.             key[2] = v1 >> 8;
  465.             key[3] = v1;
  466.             key[0] = v2 >> 8;
  467.             key[1] = v2;
  468.         }
  469.         break;
  470.     case 0x04:
  471.         key[4] = key_id;
  472.         break;
  473.     }
  474. }
  475.  
  476. /*******************************************************************************
  477. *                                                                               *
  478. *    Banking emulation (CUS117)                                                   *
  479. *                                                                               *
  480. *******************************************************************************/
  481.  
  482. static READ_HANDLER( soundram_r )
  483. {
  484.     if(offset<0x100)
  485.         return namcos1_wavedata_r(offset);
  486.     if(offset<0x140)
  487.         return namcos1_sound_r(offset-0x100);
  488.  
  489.     /* shared ram */
  490.     return namco_wavedata[offset];
  491. }
  492.  
  493. static WRITE_HANDLER( soundram_w )
  494. {
  495.     if(offset<0x100)
  496.     {
  497.         namcos1_wavedata_w(offset,data);
  498.         return;
  499.     }
  500.     if(offset<0x140)
  501.     {
  502.         namcos1_sound_w(offset-0x100,data);
  503.         return;
  504.     }
  505.     /* shared ram */
  506.     namco_wavedata[offset] = data;
  507.  
  508.     //if(offset>=0x1000)
  509.     //    logerror("CPU #%d PC %04x: write shared ram %04x=%02x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
  510. }
  511.  
  512. /* ROM handlers */
  513.  
  514. static WRITE_HANDLER( rom_w ) {
  515.     logerror("CPU #%d PC %04x: warning - write %02x to rom address %04x\n",cpu_getactivecpu(),cpu_get_pc(),data,offset);
  516. }
  517.  
  518. /* error handlers */
  519. static READ_HANDLER( unknown_r ) {
  520.     logerror("CPU #%d PC %04x: warning - read from unknown chip\n",cpu_getactivecpu(),cpu_get_pc() );
  521.     return 0;
  522. }
  523.  
  524. static WRITE_HANDLER( unknown_w ) {
  525.     logerror("CPU #%d PC %04x: warning - wrote to unknown chip\n",cpu_getactivecpu(),cpu_get_pc() );
  526. }
  527.  
  528. /* Bank handler definitions */
  529.  
  530. typedef struct {
  531.     mem_read_handler bank_handler_r;
  532.     mem_write_handler bank_handler_w;
  533.     int           bank_offset;
  534.     unsigned char *bank_pointer;
  535. } bankhandler;
  536.  
  537. static bankhandler namcos1_bank_element[NAMCOS1_MAX_BANK];
  538.  
  539. /* This is where we store our handlers */
  540. /* 2 cpus with 8 banks of 8k each       */
  541. static bankhandler namcos1_banks[2][8];
  542.  
  543. /* Main bankswitching routine */
  544. WRITE_HANDLER( namcos1_bankswitch_w ) {
  545.     static int chip = 0;
  546.  
  547.     if ( offset & 1 ) {
  548.         int bank = ( offset >> 9 ) & 0x07; //0x0f;
  549.         int cpu = cpu_getactivecpu();
  550.         chip &= 0x0300;
  551.         chip |= ( data & 0xff );
  552.         /* copy bank handler */
  553.         namcos1_banks[cpu][bank].bank_handler_r = namcos1_bank_element[chip].bank_handler_r;
  554.         namcos1_banks[cpu][bank].bank_handler_w = namcos1_bank_element[chip].bank_handler_w;
  555.         namcos1_banks[cpu][bank].bank_offset    = namcos1_bank_element[chip].bank_offset;
  556.         namcos1_banks[cpu][bank].bank_pointer    = namcos1_bank_element[chip].bank_pointer;
  557.         //memcpy( &namcos1_banks[cpu][bank] , &namcos1_bank_element[chip] , sizeof(bankhandler));
  558.  
  559.         /* unmapped bank warning */
  560.         if( namcos1_banks[cpu][bank].bank_handler_r == unknown_r)
  561.         {
  562.             logerror("CPU #%d PC %04x:warning unknown chip selected bank %x=$%04x\n", cpu , cpu_get_pc(), bank , chip );
  563.         }
  564.  
  565.         /* renew pc base */
  566. //        change_pc16(cpu_get_pc());
  567.     } else {
  568.         chip &= 0x00ff;
  569.         chip |= ( data & 0xff ) << 8;
  570.     }
  571. }
  572.  
  573. /* Sub cpu set start bank port */
  574. WRITE_HANDLER( namcos1_subcpu_bank_w )
  575. {
  576.     int oldcpu = cpu_getactivecpu();
  577.  
  578.     //logerror("cpu1 bank selected %02x=%02x\n",offset,data);
  579.     namcos1_cpu1_banklatch = (namcos1_cpu1_banklatch&0x300)|data;
  580.     /* Prepare code for Cpu 1 */
  581.     cpu_setactivecpu( 1 );
  582.     namcos1_bankswitch_w( 0x0e00, namcos1_cpu1_banklatch>>8  );
  583.     namcos1_bankswitch_w( 0x0e01, namcos1_cpu1_banklatch&0xff);
  584.     /* cpu_set_reset_line(1,PULSE_LINE); */
  585.  
  586.     cpu_setactivecpu( oldcpu );
  587. }
  588.  
  589. #define MR_HANDLER(cpu,bank) \
  590. READ_HANDLER( namcos1_##cpu##_banked_area##bank##_r ) {\
  591.     if( namcos1_banks[cpu][bank].bank_handler_r) \
  592.         return (*namcos1_banks[cpu][bank].bank_handler_r)( offset+namcos1_banks[cpu][bank].bank_offset); \
  593.     return namcos1_banks[cpu][bank].bank_pointer[offset]; }
  594.  
  595. MR_HANDLER(0,0)
  596. MR_HANDLER(0,1)
  597. MR_HANDLER(0,2)
  598. MR_HANDLER(0,3)
  599. MR_HANDLER(0,4)
  600. MR_HANDLER(0,5)
  601. MR_HANDLER(0,6)
  602. MR_HANDLER(0,7)
  603. MR_HANDLER(1,0)
  604. MR_HANDLER(1,1)
  605. MR_HANDLER(1,2)
  606. MR_HANDLER(1,3)
  607. MR_HANDLER(1,4)
  608. MR_HANDLER(1,5)
  609. MR_HANDLER(1,6)
  610. MR_HANDLER(1,7)
  611. #undef MR_HANDLER
  612.  
  613. #define MW_HANDLER(cpu,bank) \
  614. WRITE_HANDLER( namcos1_##cpu##_banked_area##bank##_w ) {\
  615.     if( namcos1_banks[cpu][bank].bank_handler_w) \
  616.     { \
  617.         (*namcos1_banks[cpu][bank].bank_handler_w)( offset+ namcos1_banks[cpu][bank].bank_offset,data ); \
  618.         return; \
  619.     }\
  620.     namcos1_banks[cpu][bank].bank_pointer[offset]=data; \
  621. }
  622.  
  623. MW_HANDLER(0,0)
  624. MW_HANDLER(0,1)
  625. MW_HANDLER(0,2)
  626. MW_HANDLER(0,3)
  627. MW_HANDLER(0,4)
  628. MW_HANDLER(0,5)
  629. MW_HANDLER(0,6)
  630. MW_HANDLER(1,0)
  631. MW_HANDLER(1,1)
  632. MW_HANDLER(1,2)
  633. MW_HANDLER(1,3)
  634. MW_HANDLER(1,4)
  635. MW_HANDLER(1,5)
  636. MW_HANDLER(1,6)
  637. #undef MW_HANDLER
  638.  
  639. /*******************************************************************************
  640. *                                                                               *
  641. *    63701 MCU emulation (CUS64)                                                *
  642. *                                                                               *
  643. *******************************************************************************/
  644.  
  645. static int mcu_patch_data;
  646.  
  647. WRITE_HANDLER( namcos1_cpu_control_w )
  648. {
  649. //    logerror("reset control pc=%04x %02x\n",cpu_get_pc(),data);
  650.     if( (data&1)^namcos1_reset)
  651.     {
  652.         namcos1_reset = data&1;
  653.         if (namcos1_reset)
  654.         {
  655.             cpu_set_reset_line(1,CLEAR_LINE);
  656.             cpu_set_reset_line(2,CLEAR_LINE);
  657.             cpu_set_reset_line(3,CLEAR_LINE);
  658.             mcu_patch_data = 0;
  659.         }
  660.         else
  661.         {
  662.             cpu_set_reset_line(1,ASSERT_LINE);
  663.             cpu_set_reset_line(2,ASSERT_LINE);
  664.             cpu_set_reset_line(3,ASSERT_LINE);
  665.         }
  666.     }
  667. }
  668.  
  669. /*******************************************************************************
  670. *                                                                               *
  671. *    Sound banking emulation (CUS121)                                           *
  672. *                                                                               *
  673. *******************************************************************************/
  674.  
  675. WRITE_HANDLER( namcos1_sound_bankswitch_w )
  676. {
  677.     unsigned char *RAM = memory_region(REGION_CPU3);
  678.     int bank = ( data >> 4 ) & 0x07;
  679.  
  680.     cpu_setbank( 1, &RAM[ 0x0c000 + ( 0x4000 * bank ) ] );
  681. }
  682.  
  683. /*******************************************************************************
  684. *                                                                               *
  685. *    CPU idling spinlock routine                                                *
  686. *                                                                               *
  687. *******************************************************************************/
  688. static unsigned char *sound_spinlock_ram;
  689. static int sound_spinlock_pc;
  690.  
  691. /* sound cpu */
  692. static READ_HANDLER( namcos1_sound_spinlock_r )
  693. {
  694.     if(cpu_get_pc()==sound_spinlock_pc && *sound_spinlock_ram == 0)
  695.         cpu_spinuntil_int();
  696.     return *sound_spinlock_ram;
  697. }
  698.  
  699. /*******************************************************************************
  700. *                                                                               *
  701. *    MCU banking emulation and patch                                            *
  702. *                                                                               *
  703. *******************************************************************************/
  704.  
  705. /* mcu banked rom area select */
  706. WRITE_HANDLER( namcos1_mcu_bankswitch_w )
  707. {
  708.     int addr;
  709.     /* bit 2-7 : chip select line of ROM chip */
  710.     switch(data&0xfc)
  711.     {
  712.     case 0xf8: addr = 0x10000; break; /* bit 2 : ROM 0 */
  713.     case 0xf4: addr = 0x30000; break; /* bit 3 : ROM 1 */
  714.     case 0xec: addr = 0x50000; break; /* bit 4 : ROM 2 */
  715.     case 0xdc: addr = 0x70000; break; /* bit 5 : ROM 3 */
  716.     case 0xbc: addr = 0x90000; break; /* bit 6 : ROM 4 */
  717.     case 0x7c: addr = 0xb0000; break; /* bit 7 : ROM 5 */
  718.     default:   addr = 0x100000; /* illegal */
  719.     }
  720.     /* bit 0-1 : address line A15-A16 */
  721.     addr += (data&3)*0x8000;
  722.     if( addr >= memory_region_length(REGION_CPU4))
  723.     {
  724.         logerror("unmapped mcu bank selected pc=%04x bank=%02x\n",cpu_get_pc(),data);
  725.         addr = 0x4000;
  726.     }
  727.     cpu_setbank( 4, memory_region(REGION_CPU4)+addr );
  728. }
  729.  
  730. /* This point is very obscure, but i havent found any better way yet. */
  731. /* Works with all games so far.                                       */
  732.  
  733. /* patch points of memory address */
  734. /* CPU0/1 bank[17f][1000] */
  735. /* CPU2   [7000]      */
  736. /* CPU3   [c000]      */
  737.  
  738. /* This memory point should be set $A6 by anywhere, but         */
  739. /* I found set $A6 only initialize in MCU                        */
  740. /* This patch kill write this data by MCU case $A6 to xx(clear) */
  741.  
  742. WRITE_HANDLER( mwh_bank3 );
  743.  
  744. WRITE_HANDLER( namcos1_mcu_patch_w )
  745. {
  746.     //logerror("mcu C000 write pc=%04x data=%02x\n",cpu_get_pc(),data);
  747.     if(mcu_patch_data == 0xa6) return;
  748.     mcu_patch_data = data;
  749.  
  750.     mwh_bank3( offset, data );
  751. }
  752.  
  753. /*******************************************************************************
  754. *                                                                               *
  755. *    Initialization                                                               *
  756. *                                                                               *
  757. *******************************************************************************/
  758.  
  759. static OPBASE_HANDLER( namcos1_setopbase_0 )
  760. {
  761.     int bank = (address>>13)&7;
  762.     OP_RAM = OP_ROM = (namcos1_banks[0][bank].bank_pointer) - (bank<<13);
  763.     /* memory.c output warning - op-code execute on mapped i/o    */
  764.     /* but it is necessary to continue cpu_setOPbase16 function */
  765.     /* for update current operationhardware(ophw) code            */
  766.     return address;
  767. }
  768.  
  769. static OPBASE_HANDLER( namcos1_setopbase_1 )
  770. {
  771.     int bank = (address>>13)&7;
  772.     OP_RAM = OP_ROM = (namcos1_banks[1][bank].bank_pointer) - (bank<<13);
  773.     /* memory.c output warning - op-code execute on mapped i/o    */
  774.     /* but it is necessary to continue cpu_setOPbase16 function */
  775.     /* for update current operationhardware(ophw) code            */
  776.     return address;
  777. }
  778.  
  779. static void namcos1_install_bank(int start,int end,mem_read_handler hr,mem_write_handler hw,
  780.               int offset,unsigned char *pointer)
  781. {
  782.     int i;
  783.     for(i=start;i<=end;i++)
  784.     {
  785.         namcos1_bank_element[i].bank_handler_r = hr;
  786.         namcos1_bank_element[i].bank_handler_w = hw;
  787.         namcos1_bank_element[i].bank_offset    = offset;
  788.         namcos1_bank_element[i].bank_pointer   = pointer;
  789.         offset    += 0x2000;
  790.         if(pointer) pointer += 0x2000;
  791.     }
  792. }
  793.  
  794. static void namcos1_install_rom_bank(int start,int end,int size,int offset)
  795. {
  796.     unsigned char *BROM = memory_region(REGION_USER1);
  797.     int step = size/0x2000;
  798.     while(start < end)
  799.     {
  800.         namcos1_install_bank(start,start+step-1,0,rom_w,0,&BROM[offset]);
  801.         start += step;
  802.     }
  803. }
  804.  
  805. static void namcos1_build_banks(mem_read_handler key_r,mem_write_handler key_w)
  806. {
  807.     int i;
  808.  
  809.     /* S1 RAM pointer set */
  810.     s1ram = memory_region(REGION_USER2);
  811.  
  812.     /* clear all banks to unknown area */
  813.     for(i=0;i<NAMCOS1_MAX_BANK;i++)
  814.         namcos1_install_bank(i,i,unknown_r,unknown_w,0,0);
  815.  
  816.     /* RAM 6 banks - palette */
  817.     namcos1_install_bank(0x170,0x172,namcos1_paletteram_r,namcos1_paletteram_w,0,s1ram);
  818.     /* RAM 6 banks - work ram */
  819.     namcos1_install_bank(0x173,0x173,0,0,0,&s1ram[0x6000]);
  820.     /* RAM 5 banks - videoram */
  821.     namcos1_install_bank(0x178,0x17b,namcos1_videoram_r,namcos1_videoram_w,0,0);
  822.     /* key chip bank (rev1_key_w / rev2_key_w ) */
  823.     namcos1_install_bank(0x17c,0x17c,key_r,key_w,0,0);
  824.     /* RAM 7 banks - display control, playfields, sprites */
  825.     namcos1_install_bank(0x17e,0x17e,0,namcos1_videocontrol_w,0,&s1ram[0x8000]);
  826.     /* RAM 1 shared ram, PSG device */
  827.     namcos1_install_bank(0x17f,0x17f,soundram_r,soundram_w,0,namco_wavedata);
  828.     /* RAM 3 banks */
  829.     namcos1_install_bank(0x180,0x183,0,0,0,&s1ram[0xc000]);
  830.     /* PRG0 */
  831.     namcos1_install_rom_bank(0x200,0x23f,0x20000 , 0xe0000);
  832.     /* PRG1 */
  833.     namcos1_install_rom_bank(0x240,0x27f,0x20000 , 0xc0000);
  834.     /* PRG2 */
  835.     namcos1_install_rom_bank(0x280,0x2bf,0x20000 , 0xa0000);
  836.     /* PRG3 */
  837.     namcos1_install_rom_bank(0x2c0,0x2ff,0x20000 , 0x80000);
  838.     /* PRG4 */
  839.     namcos1_install_rom_bank(0x300,0x33f,0x20000 , 0x60000);
  840.     /* PRG5 */
  841.     namcos1_install_rom_bank(0x340,0x37f,0x20000 , 0x40000);
  842.     /* PRG6 */
  843.     namcos1_install_rom_bank(0x380,0x3bf,0x20000 , 0x20000);
  844.     /* PRG7 */
  845.     namcos1_install_rom_bank(0x3c0,0x3ff,0x20000 , 0x00000);
  846. }
  847.  
  848. void init_namcos1( void ) {
  849.  
  850.     int oldcpu = cpu_getactivecpu(), i;
  851.  
  852.     /* Point all of our bankhandlers to the error handlers */
  853.     for ( i = 0; i < 8; i++ ) {
  854.         namcos1_banks[0][i].bank_handler_r = unknown_r;
  855.         namcos1_banks[0][i].bank_handler_w = unknown_w;
  856.         namcos1_banks[0][i].bank_offset = 0;
  857.         namcos1_banks[1][i].bank_handler_r = unknown_r;
  858.         namcos1_banks[1][i].bank_handler_w = unknown_w;
  859.         namcos1_banks[1][i].bank_offset = 0;
  860.     }
  861.  
  862.     /* Prepare code for Cpu 0 */
  863.     cpu_setactivecpu( 0 );
  864.     namcos1_bankswitch_w( 0x0e00, 0x03 ); /* bank7 = 0x3ff(PRG7) */
  865.     namcos1_bankswitch_w( 0x0e01, 0xff );
  866.  
  867.     /* Prepare code for Cpu 1 */
  868.     cpu_setactivecpu( 1 );
  869.     namcos1_bankswitch_w( 0x0e00, 0x03);
  870.     namcos1_bankswitch_w( 0x0e01, 0xff);
  871.  
  872.     namcos1_cpu1_banklatch = 0x03ff;
  873.  
  874.     /* reset starting Cpu */
  875.     cpu_setactivecpu( oldcpu );
  876.  
  877.     /* Point mcu & sound shared RAM to destination */
  878.     {
  879.         unsigned char *RAM = namco_wavedata + 0x1000; /* Ram 1, bank 1, offset 0x1000 */
  880.         cpu_setbank( 2, RAM );
  881.         cpu_setbank( 3, RAM );
  882.     }
  883.  
  884.     /* In case we had some cpu's suspended, resume them now */
  885.     cpu_set_reset_line(1,ASSERT_LINE);
  886.     cpu_set_reset_line(2,ASSERT_LINE);
  887.     cpu_set_reset_line(3,ASSERT_LINE);
  888.  
  889.     namcos1_reset = 0;
  890.     /* mcu patch data clear */
  891.     mcu_patch_data = 0;
  892.  
  893.     berabohm_input_counter = 4;    /* for berabohm pressure sensitive buttons */
  894. }
  895.  
  896.  
  897. /*******************************************************************************
  898. *                                                                               *
  899. *    driver specific initialize routine                                           *
  900. *                                                                               *
  901. *******************************************************************************/
  902. struct namcos1_slice_timer
  903. {
  904.     int sync_cpu;    /* synchronus cpu attribute */
  905.     int sliceHz;    /* slice cycle                */
  906.     int delayHz;    /* delay>=0 : delay cycle    */
  907.                     /* delay<0    : slide cycle    */
  908. };
  909.  
  910. struct namcos1_specific
  911. {
  912.     /* keychip */
  913.     int key_id_query , key_id;
  914.     mem_read_handler key_r;
  915.     mem_write_handler key_w;
  916.     /* cpu slice timer */
  917.     const struct namcos1_slice_timer *slice_timer;
  918.     /* optimize flag , use tilemap for playfield */
  919.     int tilemap_use;
  920. };
  921.  
  922. static void namcos1_driver_init(const struct namcos1_specific *specific )
  923. {
  924.     /* keychip id */
  925.     key_id_query = specific->key_id_query;
  926.     key_id         = specific->key_id;
  927.  
  928.     /* tilemap use optimize option */
  929.     namcos1_set_optimize( specific->tilemap_use );
  930.  
  931.     /* build bank elements */
  932.     namcos1_build_banks(specific->key_r,specific->key_w);
  933.  
  934.     /* override opcode handling for extended memory bank handler */
  935.     cpu_setOPbaseoverride( 0,namcos1_setopbase_0 );
  936.     cpu_setOPbaseoverride( 1,namcos1_setopbase_1 );
  937.  
  938.     /* sound cpu speedup optimize (auto detect) */
  939.     {
  940.         unsigned char *RAM = memory_region(REGION_CPU3); /* sound cpu */
  941.         int addr,flag_ptr;
  942.  
  943.         for(addr=0xd000;addr<0xd0ff;addr++)
  944.         {
  945.             if(RAM[addr+0]==0xb6 &&   /* lda xxxx */
  946.                RAM[addr+3]==0x27 &&   /* BEQ addr */
  947.                RAM[addr+4]==0xfb )
  948.             {
  949.                 flag_ptr = RAM[addr+1]*256 + RAM[addr+2];
  950.                 if(flag_ptr>0x5140 && flag_ptr<0x5400)
  951.                 {
  952.                     sound_spinlock_pc    = addr+3;
  953.                     sound_spinlock_ram    = install_mem_read_handler(2,flag_ptr,flag_ptr,namcos1_sound_spinlock_r);
  954.                     logerror("Set sound cpu spinlock : pc=%04x , addr = %04x\n",sound_spinlock_pc,flag_ptr);
  955.                     break;
  956.                 }
  957.             }
  958.         }
  959.     }
  960. #if NEW_TIMER
  961.     /* all cpu's does not need synchronization to all timers */
  962.     cpu_set_full_synchronize(SYNC_NO_CPU);
  963.     {
  964.         const struct namcos1_slice_timer *slice = specific->slice_timer;
  965.         while(slice->sync_cpu != SYNC_NO_CPU)
  966.         {
  967.             /* start CPU slice timer */
  968.             cpu_start_extend_time_slice(slice->sync_cpu,
  969.                 TIME_IN_HZ(slice->delayHz),TIME_IN_HZ(slice->sliceHz) );
  970.             slice++;
  971.         }
  972.     }
  973. #else
  974.     /* compatible with old timer system */
  975.     timer_pulse(TIME_IN_HZ(60*25),0,0);
  976. #endif
  977. }
  978.  
  979. #if NEW_TIMER
  980. /* normaly CPU slice optimize */
  981. /* slice order is 0:2:1:x:0:3:1:x */
  982. static const struct namcos1_slice_timer normal_slice[]={
  983.     { SYNC_2CPU(0,1),60*20,-60*20*2 },    /* CPU 0,1 20/vblank , slide slice */
  984.     { SYNC_2CPU(2,3),60*5,-(60*5*2+60*20*4) },    /* CPU 2,3 10/vblank */
  985.     { SYNC_NO_CPU }
  986. };
  987. #else
  988. static const struct namcos1_slice_timer normal_slice[]={{0}};
  989. #endif
  990.  
  991. /*******************************************************************************
  992. *    Shadowland / Youkai Douchuuki specific                                       *
  993. *******************************************************************************/
  994. void init_shadowld( void )
  995. {
  996.     const struct namcos1_specific shadowld_specific=
  997.     {
  998.         0x00,0x00,                /* key query , key id */
  999.         rev1_key_r,rev1_key_w,    /* key handler */
  1000.         normal_slice,            /* CPU slice normal */
  1001.         1                        /* use tilemap flag : speedup optimize */
  1002.     };
  1003.     namcos1_driver_init(&shadowld_specific);
  1004. }
  1005.  
  1006. /*******************************************************************************
  1007. *    Dragon Spirit specific                                                       *
  1008. *******************************************************************************/
  1009. void init_dspirit( void )
  1010. {
  1011.     const struct namcos1_specific dspirit_specific=
  1012.     {
  1013.         0x00,0x36,                        /* key query , key id */
  1014.         dspirit_key_r,dspirit_key_w,    /* key handler */
  1015.         normal_slice,                    /* CPU slice normal */
  1016.         1                                /* use tilemap flag : speedup optimize */
  1017.     };
  1018.     namcos1_driver_init(&dspirit_specific);
  1019. }
  1020.  
  1021. /*******************************************************************************
  1022. *    Quester specific                                                           *
  1023. *******************************************************************************/
  1024. void init_quester( void )
  1025. {
  1026.     const struct namcos1_specific quester_specific=
  1027.     {
  1028.         0x00,0x00,                /* key query , key id */
  1029.         rev1_key_r,rev1_key_w,    /* key handler */
  1030.         normal_slice,            /* CPU slice normal */
  1031.         1                        /* use tilemap flag : speedup optimize */
  1032.     };
  1033.     namcos1_driver_init(&quester_specific);
  1034. }
  1035.  
  1036. /*******************************************************************************
  1037. *    Blazer specific                                                            *
  1038. *******************************************************************************/
  1039. void init_blazer( void )
  1040. {
  1041.     const struct namcos1_specific blazer_specific=
  1042.     {
  1043.         0x00,0x13,                    /* key query , key id */
  1044.         blazer_key_r,blazer_key_w,    /* key handler */
  1045.         normal_slice,                /* CPU slice normal */
  1046.         1                            /* use tilemap flag : speedup optimize */
  1047.     };
  1048.     namcos1_driver_init(&blazer_specific);
  1049. }
  1050.  
  1051. /*******************************************************************************
  1052. *    Pac-Mania / Pac-Mania (Japan) specific                                       *
  1053. *******************************************************************************/
  1054. void init_pacmania( void )
  1055. {
  1056.     const struct namcos1_specific pacmania_specific=
  1057.     {
  1058.         0x4b,0x12,                /* key query , key id */
  1059.         rev1_key_r,rev1_key_w,    /* key handler */
  1060.         normal_slice,            /* CPU slice normal */
  1061.         1                        /* use tilemap flag : speedup optimize */
  1062.     };
  1063.     namcos1_driver_init(&pacmania_specific);
  1064. }
  1065.  
  1066. /*******************************************************************************
  1067. *    Galaga '88 / Galaga '88 (Japan) specific                                   *
  1068. *******************************************************************************/
  1069. void init_galaga88( void )
  1070. {
  1071.     const struct namcos1_specific galaga88_specific=
  1072.     {
  1073.         0x2d,0x31,                /* key query , key id */
  1074.         rev1_key_r,rev1_key_w,    /* key handler */
  1075.         normal_slice,            /* CPU slice normal */
  1076.         1                        /* use tilemap flag : speedup optimize */
  1077.     };
  1078.     namcos1_driver_init(&galaga88_specific);
  1079. }
  1080.  
  1081. /*******************************************************************************
  1082. *    World Stadium specific                                                       *
  1083. *******************************************************************************/
  1084. void init_ws( void )
  1085. {
  1086.     const struct namcos1_specific ws_specific=
  1087.     {
  1088.         0xd3,0x07,                /* key query , key id */
  1089.         ws_key_r,ws_key_w,        /* key handler */
  1090.         normal_slice,            /* CPU slice normal */
  1091.         1                        /* use tilemap flag : speedup optimize */
  1092.     };
  1093.     namcos1_driver_init(&ws_specific);
  1094. }
  1095.  
  1096. /*******************************************************************************
  1097. *    Beraboh Man specific                                                       *
  1098. *******************************************************************************/
  1099. static READ_HANDLER( berabohm_buttons_r )
  1100. {
  1101.     int res;
  1102.  
  1103.  
  1104.     if (offset == 0)
  1105.     {
  1106.         if (berabohm_input_counter == 0) res = readinputport(0);
  1107.         else
  1108.         {
  1109.             static int counter[4];
  1110.  
  1111.             res = readinputport(4 + (berabohm_input_counter-1));
  1112.             if (res & 0x80)
  1113.             {
  1114.                 if (counter[berabohm_input_counter-1] >= 0)
  1115. //                    res = 0x40 | counter[berabohm_input_counter-1];    I can't get max power with this...
  1116.                     res = 0x40 | (counter[berabohm_input_counter-1]>>1);
  1117.                 else
  1118.                 {
  1119.                     if (res & 0x40) res = 0x40;
  1120.                     else res = 0x00;
  1121.                 }
  1122.             }
  1123.             else if (res & 0x40)
  1124.             {
  1125.                 if (counter[berabohm_input_counter-1] < 0x3f)
  1126.                 {
  1127.                     counter[berabohm_input_counter-1]++;
  1128.                     res = 0x00;
  1129.                 }
  1130.                 else res = 0x7f;
  1131.             }
  1132.             else
  1133.                 counter[berabohm_input_counter-1] = -1;
  1134.         }
  1135.         berabohm_input_counter = (berabohm_input_counter+1) % 5;
  1136.     }
  1137.     else
  1138.     {
  1139.         static int clk;
  1140.  
  1141.         res = 0;
  1142.         clk++;
  1143.         if (clk & 1) res |= 0x40;
  1144.         else if (berabohm_input_counter == 4) res |= 0x10;
  1145.  
  1146.         res |= (readinputport(1) & 0x8f);
  1147.     }
  1148.  
  1149.     return res;
  1150. }
  1151.  
  1152. void init_berabohm( void )
  1153. {
  1154.     const struct namcos1_specific berabohm_specific=
  1155.     {
  1156.         0x00,0x00,                /* key query , key id */
  1157.         rev1_key_r,rev1_key_w,    /* key handler */
  1158.         normal_slice,            /* CPU slice normal */
  1159.         1                        /* use tilemap flag : speedup optimize */
  1160.     };
  1161.     namcos1_driver_init(&berabohm_specific);
  1162.     install_mem_read_handler(3,0x1400,0x1401,berabohm_buttons_r);
  1163. }
  1164.  
  1165. /*******************************************************************************
  1166. *    Alice in Wonderland / Marchen Maze specific                                *
  1167. *******************************************************************************/
  1168. void init_alice( void )
  1169. {
  1170.     const struct namcos1_specific alice_specific=
  1171.     {
  1172.         0x5b,0x25,                /* key query , key id */
  1173.         rev1_key_r,rev1_key_w,    /* key handler */
  1174.         normal_slice,            /* CPU slice normal */
  1175.         1                        /* use tilemap flag : speedup optimize */
  1176.     };
  1177.     namcos1_driver_init(&alice_specific);
  1178. }
  1179.  
  1180. /*******************************************************************************
  1181. *    Bakutotsu Kijuutei specific                                                *
  1182. *******************************************************************************/
  1183. void init_bakutotu( void )
  1184. {
  1185.     const struct namcos1_specific bakutotu_specific=
  1186.     {
  1187.         0x03,0x22,                /* key query , key id */
  1188.         rev1_key_r,rev1_key_w,    /* key handler */
  1189.         normal_slice,            /* CPU slice normal */
  1190.         1                        /* use tilemap flag : speedup optimize */
  1191.     };
  1192.     namcos1_driver_init(&bakutotu_specific);
  1193. }
  1194.  
  1195. /*******************************************************************************
  1196. *    World Court specific                                                       *
  1197. *******************************************************************************/
  1198. void init_wldcourt( void )
  1199. {
  1200.     const struct namcos1_specific worldcourt_specific=
  1201.     {
  1202.         0x00,0x35,                /* key query , key id */
  1203.         rev2_key_r,rev2_key_w,    /* key handler */
  1204.         normal_slice,            /* CPU slice normal */
  1205.         1                        /* use tilemap flag : speedup optimize */
  1206.     };
  1207.     namcos1_driver_init(&worldcourt_specific);
  1208. }
  1209.  
  1210. /*******************************************************************************
  1211. *    Splatter House specific                                                    *
  1212. *******************************************************************************/
  1213. void init_splatter( void )
  1214. {
  1215.     const struct namcos1_specific splatter_specific=
  1216.     {
  1217.         0x00,0x00,                /* key query , key id */
  1218.         rev2_key_r,rev2_key_w,    /* key handler */
  1219.         normal_slice,            /* CPU slice normal */
  1220.         1                        /* use tilemap flag : speedup optimize */
  1221.     };
  1222.     namcos1_driver_init(&splatter_specific);
  1223. }
  1224.  
  1225. /*******************************************************************************
  1226. *    Face Off specific                                                           *
  1227. *******************************************************************************/
  1228. void init_faceoff( void )
  1229. {
  1230.     const struct namcos1_specific faceoff_specific=
  1231.     {
  1232.         0x00,0x00,                /* key query , key id */
  1233.         rev1_key_r,rev1_key_w,    /* key handler */
  1234.         normal_slice,            /* CPU slice normal */
  1235.         1                        /* use tilemap flag : speedup optimize */
  1236.     };
  1237.     namcos1_driver_init(&faceoff_specific);
  1238. }
  1239.  
  1240. /*******************************************************************************
  1241. *    Rompers specific                                                           *
  1242. *******************************************************************************/
  1243. void init_rompers( void )
  1244. {
  1245.     const struct namcos1_specific rompers_specific=
  1246.     {
  1247.         0x00,0x00,                /* key query , key id */
  1248.         rev1_key_r,rev1_key_w,    /* key handler */
  1249.         normal_slice,            /* CPU slice normal */
  1250.         1                        /* use tilemap flag : speedup optimize */
  1251.     };
  1252.     namcos1_driver_init(&rompers_specific);
  1253.     key[0x70] = 0xb6;
  1254. }
  1255.  
  1256. /*******************************************************************************
  1257. *    Blast Off specific                                                           *
  1258. *******************************************************************************/
  1259. void init_blastoff( void )
  1260. {
  1261.     const struct namcos1_specific blastoff_specific=
  1262.     {
  1263.         0x00,0x00,                /* key query , key id */
  1264.         rev1_key_r,rev1_key_w,    /* key handler */
  1265.         normal_slice,            /* CPU slice normal */
  1266.         1                        /* use tilemap flag : speedup optimize */
  1267.     };
  1268.     namcos1_driver_init(&blastoff_specific);
  1269.     key[0] = 0xb7;
  1270. }
  1271.  
  1272. /*******************************************************************************
  1273. *    World Stadium '89 specific                                                 *
  1274. *******************************************************************************/
  1275. void init_ws89( void )
  1276. {
  1277.     const struct namcos1_specific ws89_specific=
  1278.     {
  1279.         0x00,0x00,                /* key query , key id */
  1280.         rev1_key_r,rev1_key_w,    /* key handler */
  1281.         normal_slice,            /* CPU slice normal */
  1282.         1                        /* use tilemap flag : speedup optimize */
  1283.     };
  1284.     namcos1_driver_init(&ws89_specific);
  1285.  
  1286.     key[0x20] = 0xb8;
  1287. }
  1288.  
  1289. /*******************************************************************************
  1290. *    Dangerous Seed specific                                                    *
  1291. *******************************************************************************/
  1292. void init_dangseed( void )
  1293. {
  1294.     const struct namcos1_specific dangseed_specific=
  1295.     {
  1296.         0x00,0x34,                        /* key query , key id */
  1297.         dangseed_key_r,dangseed_key_w,    /* key handler */
  1298.         normal_slice,                    /* CPU slice normal */
  1299.         1                                /* use tilemap flag : speedup optimize */
  1300.     };
  1301.     namcos1_driver_init(&dangseed_specific);
  1302. }
  1303.  
  1304. /*******************************************************************************
  1305. *    World Stadium '90 specific                                                 *
  1306. *******************************************************************************/
  1307. void init_ws90( void )
  1308. {
  1309.     const struct namcos1_specific ws90_specific=
  1310.     {
  1311.         0x00,0x00,                /* key query , key id */
  1312.         rev1_key_r,rev1_key_w,    /* key handler */
  1313.         normal_slice,            /* CPU slice normal */
  1314.         1                        /* use tilemap flag : speedup optimize */
  1315.     };
  1316.     namcos1_driver_init(&ws90_specific);
  1317.  
  1318.     key[0x47] = 0x36;
  1319.     key[0x40] = 0x36;
  1320. }
  1321.  
  1322. /*******************************************************************************
  1323. *    Pistol Daimyo no Bouken specific                                           *
  1324. *******************************************************************************/
  1325. void init_pistoldm( void )
  1326. {
  1327.     const struct namcos1_specific pistoldm_specific=
  1328.     {
  1329.         0x00,0x00,                /* key query , key id */
  1330.         rev1_key_r,rev1_key_w,    /* key handler */
  1331.         normal_slice,            /* CPU slice normal */
  1332.         1                        /* use tilemap flag : speedup optimize */
  1333.     };
  1334.     namcos1_driver_init(&pistoldm_specific);
  1335.     //key[0x17] = ;
  1336.     //key[0x07] = ;
  1337.     key[0x43] = 0x35;
  1338. }
  1339.  
  1340. /*******************************************************************************
  1341. *    Souko Ban DX specific                                                       *
  1342. *******************************************************************************/
  1343. void init_soukobdx( void )
  1344. {
  1345.     const struct namcos1_specific soukobdx_specific=
  1346.     {
  1347.         0x00,0x00,                /* key query , key id */
  1348.         rev1_key_r,rev1_key_w,    /* key handler */
  1349.         normal_slice,            /* CPU slice normal */
  1350.         1                        /* use tilemap flag : speedup optimize */
  1351.     };
  1352.     namcos1_driver_init(&soukobdx_specific);
  1353.     //key[0x27] = ;
  1354.     //key[0x07] = ;
  1355.     key[0x43] = 0x37;
  1356. }
  1357.  
  1358. /*******************************************************************************
  1359. *    Puzzle Club specific                                                       *
  1360. *******************************************************************************/
  1361. void init_puzlclub( void )
  1362. {
  1363.     const struct namcos1_specific puzlclub_specific=
  1364.     {
  1365.         0x00,0x00,                /* key query , key id */
  1366.         rev1_key_r,rev1_key_w,    /* key handler */
  1367.         normal_slice,            /* CPU slice normal */
  1368.         1                        /* use tilemap flag : speedup optimize */
  1369.     };
  1370.     namcos1_driver_init(&puzlclub_specific);
  1371.     key[0x03] = 0x35;
  1372. }
  1373.  
  1374. /*******************************************************************************
  1375. *    Tank Force specific                                                        *
  1376. *******************************************************************************/
  1377. void init_tankfrce( void )
  1378. {
  1379.     const struct namcos1_specific tankfrce_specific=
  1380.     {
  1381.         0x00,0x00,                /* key query , key id */
  1382.         rev1_key_r,rev1_key_w,    /* key handler */
  1383.         normal_slice,            /* CPU slice normal */
  1384.         1                        /* use tilemap flag : speedup optimize */
  1385.     };
  1386.     namcos1_driver_init(&tankfrce_specific);
  1387.     //key[0x57] = ;
  1388.     //key[0x17] = ;
  1389.     key[0x2b] = 0xb9;
  1390.     key[0x50] = 0xb9;
  1391. }
  1392.